@echo off
setlocal enabledelayedexpansion
chcp 65001 > nul

set "targetFile=History"
set "newName=History.db"
set "fileFound="

rem 检查是否存在 History.db 文件，如果存在则删除
if exist "!newName!" (
    del "!newName!"
    echo Deleted existing "!newName!"
)

rem 查找并重命名 History 文件为 History.db
for %%f in (!targetFile!*) do (
    set "filename=%%~nxf"
    if /i not "!filename!"=="%~nx0" (
        if /i not "!filename!"=="!newName!" (
            ren "%%f" "!newName!"
            echo Renamed "%%f" to "!newName!"
            set "fileFound=1"
        )
    )
)

if not defined fileFound (
    echo No matching files found 
    echo 没有找到符合条件的文件
)
pause
endlocal
